const path = require('path');

const { pathAlias } = require('./my-config');

function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    publicPath: './',
    outputDir: 'dist',
    assetsDir: 'static',
    productionSourceMap: false,
    devServer: {
        port: 2000,
        open: false,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {  //配置跨域
            '/service': {
                target: 'http://freeout.goho.co:55917/nqs-web',
                changOrigin: true,  //允许跨域
                pathRewrite: {
                    '^/service': ''
                }
            }
        }
    },

    configureWebpack: {
        externals: {
            'BMap': 'BMap',
            'BMap_Symbol_SHAPE_POINT': 'BMap_Symbol_SHAPE_POINT'
        }
    },

    //配置别名
    chainWebpack: (config) => {
        let alias = config.resolve.alias;
        for (let index in pathAlias) {
            alias.set(index, resolve(pathAlias[index]));
        }
    },
}
